package com.dob.patterns;


/**
 * Steps:
 * 1. Making class final so no sub class can extend it
 * 2. Making constructor private so object can not be created outside the class
 * 3. Create the instance inside Synchronized block, will not be any issue in case of multi threading environment. 
 * 4. Instance can be eagerly initialized at the time of class loading.
 * 
 * 
 * @author Santosh
 *
 */



public final class SingletonPattern {

	private static SingletonPattern singleton;
	private static SingletonPattern instance1234
	
	private SingletonPattern(){
		
	}
	
	public static SingletonPattern getInstance(){
		synchronized (SingletonPattern.class) {
			if(singleton == null){
				singleton= new SingletonPattern();
			}
		}
		return singleton;
	}
	
	public SingletonPattern getSingleton(){
		return instance;
	}
	
//	private static SingletonPattern instance= new SingletonPattern();
//	public static SingletonPattern getInstance(){
//		return instance;
//	}
}
